<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/4
 * Time: 16:14
 */

namespace app\common\validate;

class User extends \think\Validate
{
    protected $rule = [
        'name|用户名'  =>  'require|max:25',
        'password|密码'  =>  'require|max:25|confirm',
        'QQ' =>  'number|max:11',
        'uid' =>  'require|number',
        'code'=>'number',
        'mail|邮箱'=>'email',
        'mobile|手机'=>'require|max:11',
        'status' =>'number|in:1,2,3',
//        'captcha|验证码'=>'require|captcha',
        'status' => 'number|in:2,1,0',
    ];

    protected $message = [
        'name.require'  =>  '用户名不能为空',
        'password.require'  =>  '密码不能为空',
        'status'=>'校验范围不合法',
    ];

    protected $scene = [
        'add'   =>  ['name'=>'unique:user|require|max:25','password','mobile','name','mail'=>'unique:user|require|email','captcha'],
        'edit'  =>  ['password'=>'requireWith:password|max:25|confirm','mobile'=>'requireWith','mail','QQ'],
        'pub' =>['captcha','name','password'=>'require'],
        'checkpwd' =>['captcha','name','mail'],
    ];

}